package com.restaurant.application.indexes.signinlist.mysql;

import com.google.common.collect.Lists;
import com.nebutown.generation.Convert;
import com.nebutown.generation.PickableBean;
import com.nebutown.generation.basictype.UID;

import java.util.List;

public class SignInListBean implements PickableBean {

    public static final String FN_RECORDID = "recordId";
    public static final String FN_SIGNINUID = "signInUid";
    public static final String FN_SIGNTIME = "signTime";
    public static final String FN_CUSTOMERUID = "customerUid";
    public static final String FN_CUSTOMERNAME = "customerName";
    public static final String FN_REALNAME = "realName";

    public static final List<String> FIELD_NAMES = Lists.newArrayList(
             FN_RECORDID,
             FN_SIGNINUID,
             FN_SIGNTIME,
             FN_CUSTOMERUID,
             FN_CUSTOMERNAME,
             FN_REALNAME);

    private Long recordId;
    private UID signInUid;
    private Long signTime;
    private UID customerUid;
    private String customerName;
    private String realName;

    public SignInListBean(Long recordId, UID signInUid, Long signTime, UID customerUid, String customerName, String realName) {
        setRecordId(recordId);
        setSignInUid(signInUid);
        setSignTime(signTime);
        setCustomerUid(customerUid);
        setCustomerName(customerName);
        setRealName(realName);
    }

    public SignInListBean() {
    }

    public SignInListBean duplicate() {
        SignInListBean result = new SignInListBean();
        result.recordId = this.recordId;
        result.signInUid = this.signInUid;
        result.signTime = this.signTime;
        result.customerUid = this.customerUid;
        result.customerName = this.customerName;
        result.realName = this.realName;
        return result;
    }

    @Override
    public String toString() {
        return Convert.toJson(this);
    }

    public Long getRecordId() {
        return recordId;
    }

    public void  setRecordId(Long value) {
        this.recordId = value;
    }

    public SignInListBean withRecordId(Long value) {
        setRecordId(value);
        return this;
    }

    public SignInListBean withRecordId(Long value, Long defaultValue) {
        setRecordId(value == null ? defaultValue : value);
        return this;
    }

    public UID getSignInUid() {
        return signInUid;
    }

    public void  setSignInUid(UID value) {
        this.signInUid = value;
    }

    public SignInListBean withSignInUid(UID value) {
        setSignInUid(value);
        return this;
    }

    public SignInListBean withSignInUid(UID value, UID defaultValue) {
        setSignInUid(value == null ? defaultValue : value);
        return this;
    }

    public Long getSignTime() {
        return signTime;
    }

    public void  setSignTime(Long value) {
        this.signTime = value;
    }

    public SignInListBean withSignTime(Long value) {
        setSignTime(value);
        return this;
    }

    public SignInListBean withSignTime(Long value, Long defaultValue) {
        setSignTime(value == null ? defaultValue : value);
        return this;
    }

    public UID getCustomerUid() {
        return customerUid;
    }

    public void  setCustomerUid(UID value) {
        this.customerUid = value;
    }

    public SignInListBean withCustomerUid(UID value) {
        setCustomerUid(value);
        return this;
    }

    public SignInListBean withCustomerUid(UID value, UID defaultValue) {
        setCustomerUid(value == null ? defaultValue : value);
        return this;
    }

    public String getCustomerName() {
        return customerName;
    }

    public void  setCustomerName(String value) {
        this.customerName = value;
    }

    public SignInListBean withCustomerName(String value) {
        setCustomerName(value);
        return this;
    }

    public SignInListBean withCustomerName(String value, String defaultValue) {
        setCustomerName(value == null ? defaultValue : value);
        return this;
    }

    public String getRealName() {
        return realName;
    }

    public void  setRealName(String value) {
        this.realName = value;
    }

    public SignInListBean withRealName(String value) {
        setRealName(value);
        return this;
    }

    public SignInListBean withRealName(String value, String defaultValue) {
        setRealName(value == null ? defaultValue : value);
        return this;
    }

    public Object getValueOf(String name) {
        switch(name) {
        case "recordId": return getRecordId();
        case "signInUid": return getSignInUid();
        case "signTime": return getSignTime();
        case "customerUid": return getCustomerUid();
        case "customerName": return getCustomerName();
        case "realName": return getRealName();
        }
        return null;
    }

    public boolean hasField(String name) {
        return FIELD_NAMES.contains(name);
    }

    @Override
    public int hashCode() {
        return signature().hashCode();
    }

    @Override
    public boolean equals(Object o) {
        if(!(o instanceof SignInListBean)) return false;
        return signature().equals(((SignInListBean)o).signature());
    }

    public String signature() {
        throw new RuntimeException("Bean SignInListBean has no signature defined, no hash code or equals possible.");
    }
}
